#include "bookinfo.h"
#include "ui_bookinfo.h"

BookInfo::BookInfo(Book bookinfo,int row,QWidget *parent) :
    QWidget(parent),
    ui(new Ui::BookInfo)
{
    ui->setupUi(this);
    ui->LineEdit_author->setText(bookinfo.author);
    ui->lineEdit_isbn->setText(bookinfo.isbn);
    ui->lineEdit_language->setText(bookinfo.language);
    ui->lineEdit_price->setText(QString::number(bookinfo.price,'g',2));
    ui->lineEdit_publish->setText(bookinfo.publish);
    ui->lineEdit_type_id->setText(bookinfo.type_id==0?"文学类":"历史类");
    ui->LineEdit_bookname->setText(bookinfo.name);
    ui->publish_data->setDate(QDate::fromString(bookinfo.publish_data,"yyyy/MM/dd"));
    ui->lineEdit_introduction->setText(bookinfo.introduction);
    ui->LineEdit_author->setEnabled(false);
    ui->lineEdit_isbn->setEnabled(false);
    ui->lineEdit_language->setEnabled(false);
    ui->lineEdit_price->setEnabled(false);
    ui->lineEdit_publish->setEnabled(false);
    ui->lineEdit_type_id->setEnabled(false);
    ui->LineEdit_bookname->setEnabled(false);
    ui->publish_data->setEnabled(false);
    ui->lineEdit_introduction->setEnabled(false);
    index = row;
}

BookInfo::~BookInfo()
{
    delete ui;
}

void BookInfo::on_pushButton_clicked()
{
    ////在这里添加归还书籍所需要更新数据库的信息
    emit signals_BookInfo(index);
    QMessageBox::about(this,"提示","还书成功");
    this->close();
}

void BookInfo::on_pushButton_2_clicked()
{
    this->close();
}
